package cn.honglian.basic.dto;

import cn.honglian.org.domain.Employee;
import cn.honglian.org.domain.Shop;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;

@Data
public class ShopSettlementDto {
        private Long id;
    @NotBlank(message = "姓名不能为空")
    private String name;
    @NotBlank(message = "电话不能为空")
    private String tel;
    @NotBlank(message = "地址不能为空")
    private String address;

    private String logo;

    @NotNull(message = "个人信息不能为空")
    private EmployeeDto admin;

    public Shop getShop(){
        return Shop.builder()
                .name(this.name)
                .tel(this.tel)
                .address(this.address)
                .logo(this.logo)
                .registerTime(new Date())
                .state(0)
                .build();
    }

    public Employee getEmp(){
        Employee employee = new Employee();
        BeanUtils.copyProperties(admin,employee);
        employee.setAge(18);
        employee.setState(1);
        return employee;
    }

}
